/**
 * @file signal_test.c
 * @author liangwenhao (1943080020@qq.com)
 * @brief 
 * @version 0.1
 * @date 2021-07-28
 * 
 * @copyright Copyright (c) 2021
 * 
 * @authorGitee  https://gitee.com/liangwenhao
 * @authorGithub https://github.com/WHaoL
 * @authorBlogs https://blog.csdn.net/liangwenhao1108
 *  
 * @Code Description: 测试signal()函数  P256
 *  
 */
#include "apue.h"

static void sig_int_handler(int signo)
{
    printf("caught SIGINT\n"); //sigint信号 Ctrl+c会触发
}

static void sig_quit_handler(int signo)
{
    printf("caught SIGQUIT\n"); //sigquit信号，Ctrl+\会触发
}

int main(void)
{
    if (signal(SIGINT, sig_int_handler) == SIG_ERR)
        err_sys("signal(SIGINT) error");

    if (signal(SIGQUIT, sig_quit_handler) == SIG_ERR)
        err_sys("signal(SIGQUIT) error");

    while (1)
        sleep(1);
}

// kill -9 pid